﻿@using Banking.Domain;

@model Banking.Domain.Person


@{
    ViewBag.Title = "ViewHistory";
    Layout = "~/Views/Shared/_Layout.cshtml";
    // getting all operations in which current person participates
    var ops = Model.Operations.
        Where(op => op.Participants.
            Any(man => man.Name == Model.Name));
}

@Html.Partial("ViewHeading")


<table class="tableView tablesorter" id="history">
    <caption>
        <p>History</p>
        <p class="actionsMenu">
            <button data-action="delete" data-entity="operation" disabled><img src="../../Content/images/delete.png" /> Delete selected</button>
        </p>
    </caption>
    <thead>
        <tr id="headings">
            <th scope="col" class="checkCol"><input type="checkbox" id="selectAll" data-action="selectAll" data-entity="operation" data-view="viewPersonal"/></th>
            <th scope="col" data-action="sort" class="sortable" data-sort-key="mark">Mark</th>
            <th scope="col" data-action="sort" class="sortable" data-sort-key="amount">Total</th>
            <th scope="col" data-action="sort" class="sortable" data-sort-key="share">Part</th>
            <th scope="col" data-action="sort" class="sortable" data-sort-key="description">Description</th>
            <th scope="col" data-action="sort" class="sortable" data-sort-key="date">Date</th>
            <th scope="col" data-action="sort" class="sortable" data-sort-key="others">Others</th>
        </tr>
    </thead>
    <tbody data-list="operation" data-sort-key="date" data-sort-order="descending" data-view="viewPersonalOperation">
        @foreach (var op in ops)
        {
            @Html.Action("ViewPersonal", "Operation", new { id=op.ID, ownerId=Model.ID });
        }
    </tbody>
</table>